package com.kaifamiao.www.demo.Do26.Zuoye;

import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        Student[] stu = new Student[5];
        for(int i = 0;i <= 4;i++){
            stu[i] = new Student();
        }
        Scanner sc = new Scanner(System.in);
        for (int i = 0;i<stu.length;i++){
            System.out.println("请输入第"+(i+1)+"个学生的姓名");
            stu[i].name=sc.next();
            System.out.println("请输入第"+(i+1)+"个学生的学号");
            stu[i].no=sc.nextInt();
            System.out.println("请输入第"+(i+1)+"个学生的成绩");
            stu[i].score=sc.nextInt();
        }
        for(int n = 0;n <stu.length-1;n++ ){
            for(int x = 0;x<stu.length-n-1;x++){
                if(stu[x].score>stu[x+1].score){
                    Student y =stu[x];
                    stu[x]=stu[x+1];
                    stu[x+1] = y;
                }
            }
        }
        for(int x = 0;x<stu.length;x++){
            System.out.println(stu[x].name+"的学号是 "+stu[x].no+"的成绩是 "+stu[x].score);
        }
    }
}
